import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({
    state:{
        location:'鞍山',
        recentCities:['鞍山'],
        district:'永乐公园'
    },
    mutations:{
        changeCity(state,address){
            state.location = address;//更改当前所在城市
            if(!state.recentCities.includes(address)){//最近访问城市中不含该城市的时候需要将其加入最近访问城市的数组1
                state.recentCities.push(address);
            }
            
        },
        changeDistrict(state,district) {
            state.district = district;
        }
    }
});